<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function newInterval(func, millisecond) {
            function inside() {
                func();
                setTimeout(inside, millisecond);
            }
            setTimeout(inside, millisecond)
        }

        function f() {
            console.log('用setTimeout实现setInterval！')
        }
        newInterval(f, 1000);
    </script>
</body>

</html>